<?php
namespace app\admin\controller;
use think\Controller;
use app\admin\controller\Common;
use think\Db;
class Wxpublic extends Common{
	public function userlist(){

	}
	public function replymsglist(){
		$data=Db::table("zz_public_msg")->where("msg_type","1")->select();
		//echo "<pre>";
		//查询商品详情
		foreach ($data as $key => $value) {
			$goodinfo=Db::table("zz_goods")->where("goods_id",$value["goods_id"])->find();
			$data[$key]["goodinfo"]=$goodinfo;
		}
		//var_dump($data);die;
		$this->assign("data",$data);
		return $this->fetch();
	}

	
	function wxsendmorenews($touser){
	
		$APPID="wx70fc5921f110b164";
		$APPSECRET="945ad23b429e15daaea874405e913eba";
		
		$TOKEN_URL="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$APPID."&secret=".$APPSECRET;
		$json=file_get_contents($TOKEN_URL);
		$result=json_decode($json);
		print_r($result);
		echo $result->access_token;
		$ACC_TOKEN=$result->access_token;
		
		$sql2="select * from information where id='$msgid'";
		$conn2=mysql_query($sql2);
		$rs2=mysql_fetch_array($conn2);
		$image=array_filter(explode('|',$rs2["image"]));
		$title=array_filter(explode('|',$rs2["title"]));
		$url=array_filter(explode('|',$rs2["url"]));
		$content="亿捷物业";
		$data = '{
		    "touser":"'.$touser.'",
		    "msgtype":"news",
		    "news":
		    {';
			$i=0;
			foreach($url as $key=>$value){
				$data=$data.'	"articles": [
					 {
						 "title":"'.$title[$i].'",
						 "description":"'.$content.'",
						 "url":"http://yijie.hzbrxx.com/phone/news.php?uid='.$url[$i].'",
						 "picurl":"http://yijie.hzbrxx.com/admin/images/'.$image[$i].'"
					 }
				 ],';
				 $i=$i+1;
			}
		    $data=$data.'}
		}';
		$url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=".$ACC_TOKEN;
		
		$result = https_post($url,$data);
		$final = json_decode($result);
		echo $final->errmsg;
		return $final;

	}
}